/*
    3. Write a program in C to separate the individual characters from a string. 

    Test Data :
    Input the string : w3resource.com

    Expected Output :

    The characters of the string are : 
    w  3  r  e  s  o  u  r  c  e  .  c  o  m 
*/

#include <stdio.h>
#include <stdlib.h>

char* getStr(char *str)
{
    char ch;
    char *p = str;
    while((ch = getchar()) != '\n'){
        *p = ch;
        p++;
    }
    *p = '\0';
    return str;
}

int getStrLen(char *str)
{
    int len = 0;
    char *p = str;
    while(*p != '\0'){
        len++;
        p++;
    }
    len++; // '\0'
    return len;
}

int main(void)
{
    char *str = malloc(1024);
    int i = 0, len;
    printf("Input the string : ");
    getStr(str);
    len = getStrLen(str);    
    printf("The characters of the string are :\n ");
    while(i < len - 1){
        printf("%c  ", str[i++]);
    }

    return 0;
}